﻿Namespace MRUItems
    <DebuggerDisplay("ProjectMRUItem: Name = {Name}, ItemText = {ItemText}")>
    Friend MustInherit Class ProjectMRUItem
        Inherits BaseMRUItem

        Public Overrides Function Populate(szName As String, szItemText As String) As Boolean
            Try
                Name = szName
                ItemText = szItemText

                Dim aszParts As String() = szItemText.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                Dim bPinned As Boolean? = Nothing
                If aszParts.Length > 1 Then
                    ' Visual studio 2010+ format
                    Path = aszParts(0)
                    bPinned = MRUConvert.ToNullableBoolean(aszParts(1))
                Else
                    Path = szItemText
                End If

                Pinned = bPinned.HasValue AndAlso bPinned.Value
                Return True
            Catch oExp As Exception
                ' If we have an exception in the constructor, 
                ' we need to dispose of resources allocated before the exception occured. 
                LogException(oExp)
                Throw
            End Try
        End Function
    End Class
End Namespace